export default{
	show:(Title:string,content:string,showCancel:boolean=false)=>{
		return new Promise((resolve, reject) =>{
			wx.showModal({
        title: Title,
        content: content,
        showCancel: showCancel, 
        editable: false,
        placeholderText: 'placeholder'
      })
      .then(res => {
        resolve(res);
      })
      .catch(err => {
        reject(err);
      })
		})
	},
	confirm:(Title:string,content:string)=>{
    return new Promise((resolve, reject) =>{
			wx.showModal({
        title: Title,
        content: content,
        showCancel: true, 
        editable: false,
        placeholderText: 'placeholder',
        success (res) {
          if (res.confirm) {
            resolve(res)
          } else if (res.cancel) {
            throw "用户点击取消";
          }
        }
      })
		})
  },
  Loading:(Title:string='加载中')=>{
    wx.showLoading({
      title:Title,
    })
  },
  hideLoading:()=>{
    wx.hideLoading();
  },
  // 展示选项框
  ActionSheet: (menu:Array<string>, title:string='') => {
    return new Promise((resolve, reject) => {
      wx.showActionSheet({
        itemList: menu,
        alertText: title,
        success: (res) => {
          resolve(res);
        },
        fail: err => {
          reject(err);
        }
      })
    })
  },
}